package com.vertx.cluster;

import com.vertx.util.Runner;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.eventbus.EventBus;

public class Sender extends AbstractVerticle {

	@Override
	public void start() throws Exception {
		EventBus eb = vertx.eventBus();

		// Send a message every second

		vertx.setPeriodic(3000, v -> {

			eb.request("my-address", "ping!" + System.currentTimeMillis(), reply -> {
				if (reply.succeeded()) {
					System.out.println("Received reply " + reply.result().body());
				} else {
					System.out.println("No reply");
				}
			});

		});
	}
}
